﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mime;
using System.ServiceModel.Channels;
using System.ServiceModel.Web;

namespace JXT.PrimaryKey.Batman.Core.WcfService
{
    public class WebJsonHttpServiceErrorHandler : WebHttpServiceErrorHandlerBase
    {
        protected override Message CreateFaultMessage(WebHttpError error)
        {
            WebOperationContext.Current.OutgoingResponse.ContentType = "application/json";
            WebOperationContext.Current.OutgoingResponse.StatusCode = (System.Net.HttpStatusCode)error.Status;
            var fault = WebOperationContext.Current.CreateJsonResponse<WebHttpError>(error);
            return fault;
        }
    }
}
